package com.example.day3.stream;

import java.util.stream.IntStream;

/**
 * <h3>查找与判断</h3>
 * 判断
 * <ol>
 *     <li>随便一个满足条件, 返回 true stream.anyMatch(x -> boolean)</li>
 *     <li>所有都满足条件, 才返回 true stream.allMatch(x -> boolean)</li>
 *     <li>所有都不满足条件, 才返回 true stream.noneMatch(x -> boolean)</li>
 * </ol>
 */
public class C08MatchTest {
    public static void main(String[] args) {
        IntStream stream = IntStream.of(1, 2, 3, 4, 5);
        // 随便一个满足条件, 返回 true
        System.out.println(stream.anyMatch(x -> (x & 1) == 0));
        // 所有都满足条件, 才返回 true
        System.out.println(stream.allMatch(x -> (x & 1) == 0));
        // 所有都不满足条件, 才返回 true
        System.out.println(stream.noneMatch(x -> (x & 1) == 0));
    }
}
